<template>
	<om-page :title="pageTitle">
		<view class="page__bd">
			<view class="nodata" v-show="datas.length == 0">暂无数据！</view>
			<uni-list>
				<view v-for="(item, index) in datas" :key="index">
					<uni-list-item :showArrow="false" :title="item.time"
						:extraText="item.printerAlias?item.printerAlias:item.printerNo"></uni-list-item>
				</view>
			</uni-list>
		</view>
	</om-page>
</template>

<script>
	export default {
		data() {
			return {
				datas: [],
				pageTitle: ""
			};
		},
		methods: {
			reloadData() {
				let _that = this;
				_that.datas = []
				_that.om.request('wxAttend/getTodayList').then(res => {
					if (res.succeed) {
						_that.datas = res.value
					}
				});
			}
		},
		onLoad(options) {
			this.pageTitle = options.title || "今日考勤"
			uni.setNavigationBarTitle({
				title: this.pageTitle
			});
			this.reloadData();
		},
		onPullDownRefresh: function() {
			let _that = this;
			_that.reloadData().then(
				res => {
					uni.stopPullDownRefresh();
					_that.om.toast('刷新成功');
				},
				err => {
					uni.stopPullDownRefresh();
				}
			);
		}
	};
</script>

<style>
	.nodata {
		width: calc(100% - 30px);
		margin: 30px 15px 0;
		height: 26px;
		line-height: 26px;
		background: none;
	}
</style>